import { observable, action } from 'mobx'
import http from 'utils/http'

async function getBanner(type) {
  const res = await http.get('banner/list', { type })
  if (res.code === 1) {
    return res.data.data
  }
  throw new Error(res.info)
}

class PictureStore {
  @observable indexBannerList = []
  @observable creditBanerList = []

  @action
  async getIndexBaner() {
    const type = 1
    const indexBannerList = await getBanner(type)
    this.indexBannerList = indexBannerList
  }

  async getCreditBaner() {
    const type = 2
    const creditBanerList = await getBanner(type)
    this.creditBanerList = creditBanerList
  }
}


const pictureStore = new PictureStore()

export default pictureStore
export { PictureStore }
